package com.itheima.test03;

import java.io.*;
import java.util.ArrayList;

/*
题目三：
	1. 请定义一个Student类，属性：姓名、性别、年龄、分数
	   无参、全参构造方法
	   get/set方法
	2. 定义测试类，编写main()方法：
		//1.定义一个集合
		List<Student> stuList = new ArrayList<>();
		stuList.add(new Student(“张三”,”男”,20,88);
		stuList.add(new Student(“李四”,”女”,19,99);
	3. 遍历这个集合，将每个Student对象中的数据按以下格式写到项目根目录下
	  的student.txt中：
	[Student{name='zhangsan', gender='nan',age=20,score=88},
	Student{name='lisi', gender='nv',age=19,score=99}]
 */
public class Test03 {
    public static void main(String[] args) throws IOException {
        ArrayList<Student> stuList = new ArrayList<>();
        stuList.add(new Student("zhangsan","nan",20,88));
        stuList.add(new Student("lisi","nv",19,99));

        String s = "";
        for (Student student : stuList) {
            s = s + "{name='" +student.getName() + "',gender='" + student.getGender() + "',age=" + student.getAge() + ",score=" + student.getScroe() + "}\n";
        }
        FileOutputStream fos = new FileOutputStream("D:\\IdeaProjects\\studentManagerSystem\\homework0917\\student.txt",true);
        fos.write(s.getBytes());
        fos.close();

    }
}
